from sqlalchemy import Column,Integer,String
from flask_sqlalchemy import SQLAlchemy
# sqlalchemy 第三方 数据库映射 独立
# Flask_SQLAlchemy 

db = SQLAlchemy()


# 专注业务模型的设计，而不是专注数据库设计
class Book(db.Model):
  id = Column(Integer, primary_key=True, autoincrement=True)
  title = Column(String(50), nullable=False)
  author = Column(String(30), default='未名')
  binding = Column(String(20))
  publisher = Column(String(50))
  price = Column(String(20))
  pages = Column(Integer)
  pubdate = Column(String(20))
  isbn = Column(String(15), nullable=False, unique=True)
  summary = Column(String(1000))
  image = Column(String(50)) 

  # MVC M 是model 处理业务逻辑
  # ORM 对象关系映射 增删改查 通过操作模型操作数据库
  def sample(self):
    pass

